import React, { useState } from 'react';
import ReactDOM from 'react-dom';
/* 
  高阶组件(高阶函数)  就是一个函数接收一个组件 然后在返回一个组件
*/

// function connect(Com) {
//   return function (props) {
//     return <Com name="珠峰" age='12' {...props} />
//   }
// }

function connect(cb1, cb2) {
  let state = {
    a: 123,
    b: 345
  }
  function setState() { }
  let res1 = cb1(state)
  let res2 = cb2(setState)
  return function (Com) {
    return function (props) {
      return <Com {...props} {...res1} {...res2} />
    }
  }
}
class App extends React.Component {

  render() {
    console.log(this.props)
    return <div className=''>

    </div>;
  }
}
App = connect((state) => {
  return {
    a: state.a,
    q: 66,
    r: 888
  }
}, (dispatch) => {
  return {
    dispatch
  }
})(App)

ReactDOM.render(<App className='box' />, document.getElementById('root'))